//获取系统时间
var newDate = '';
getLangDate();
//值小于10时，在前面补0
function dateFilter(date){
    if(date < 10){return "0"+date;}
    return date;
}
function getLangDate(){
    var obj = new Date(); //表示当前系统时间的Date对象
    var year = obj.getFullYear(); //当前系统时间的完整年份值
    var month = obj.getMonth()+1; //当前系统时间的月份值
    var date = obj.getDate(); //当前系统时间的月份中的日
    var day = obj.getDay(); //当前系统时间中的星期值
    var weeks = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
    var week = weeks[day]; //根据星期值，从数组中获取对应的星期字符串
    var hour = obj.getHours(); //当前系统时间的小时值
    var minute = obj.getMinutes(); //当前系统时间的分钟值
    var second = obj.getSeconds(); //当前系统时间的秒钟值
    var timeValue = "" +((hour >= 12) ? (hour >= 18) ? "晚上" : "下午" : "上午" ); //当前时间属于上午、晚上还是下午
    newDate = dateFilter(year)+"年"+dateFilter(month)+"月"+dateFilter(date)+"日 "+" "+dateFilter(hour)+":"+dateFilter(minute)+":"+dateFilter(second);
    document.getElementById("sysTime").innerHTML = timeValue+"好！欢迎使用后台管理系统。当前时间为："+newDate+"　"+week;
    setTimeout("getLangDate()",1000);
}

layui.use(['form','element','layer','jquery','table'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        element = layui.element;
        tab = layui.table;
        $ = layui.jquery;

    var sysLogs = tab.render({
        elem: "#sysLogs",
        url: '/logs/getAllPageLogs',
        cellMinWidth: 95,
        limit: 10,
        limits: [5, 10, 15, 20, 25],
        page: true,
        loading:true,
        response: {
            statusName: 'code'
            , statusCode: 200
            , msgName: 'msg'
            , countName: 'count'
            , dataName: 'data'
        },
        id: 'sysLogs',
        cols: [[
            {type: "checkbox", fixed: "left", width: 50},
            {field: 'id',hide:true, title: 'ID', width: 60, align: "center"},
            {field: 'ip', title: '登录ip', align: 'center',width:200},
            {field: 'ipSource', title: 'ip来源', align: 'center',width:300},
            {field: 'browser', title: '浏览器信息', align: 'center'},
            {field: 'loginDate', title: '登录日期', align: 'center'}
        ]],
        done: function(res, curr, count){//渲染成功后回调
            dispalyFeedback();
        }
    });

    /**
     * 渲染反馈时间线
     */
    function dispalyFeedback() {
        var str = "";
        $.ajax({
            url:'/homepage/getAll',
            type:'GET',
            success:function (res) {

                for (var data in res.data){
                    console.log(res.data[data])
                    str+= '<li class="layui-timeline-item">\n' +
                        '                <i class="layui-icon layui-timeline-axis">&#xe63f;</i>\n' +
                        '                <div class="layui-timeline-content layui-text">\n' +
                        '                    <h3 class="layui-timeline-title">'+res.data[data].feedbackTime +'</h3>\n' +
                        '                    <p>\n' +
                                                res.data[data].message+
                        '                    </p>\n' +
                        '                </div>\n' +
                        '            </li>'
                }
                $("#feedback").html(str);
            }
        })
    }
});